package com.motong.gongdan.vo.system.exceptionHandle.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.List;

@ApiModel("异常通知设置返回列表")
@Data
@Accessors(chain = true)
public class ExceptionGetNoticeListVo {

    @ApiModelProperty(value = "id")
    private Long id;

    /**
     * 延时时长(分钟)
     */
    @ApiModelProperty(value = "延时时长(分钟)")
    private Integer delayTime;


    /**
     * 通知人员id(多个以,号隔开)
     */
    @ApiModelProperty(value = "通知人员id(多个以,号隔开)")
    private String infoUserId;

    /**
     * 通知人员名称(多个以,号隔开)
     */
    @ApiModelProperty(value = "通知人员名称(多个以,号隔开)")
    private String infoUserName;

    /**
     * 通知方式(0 微信,1 邮箱, 2 AI语音) 多个以,号隔开
     */
    @ApiModelProperty(value = "通知方式(0 微信,1 邮箱, 2 AI语音)")
    private String infoType;

    /**
     * 通知方式名称
     */
    @ApiModelProperty(value = "通知方式名称", hidden = true)
    private String infoTypeName;


    public ExceptionGetNoticeListVo setInfoType(String infoType) {
        if (StringUtils.hasLength(infoType)) {
            List<String> typeValues = Arrays.asList(infoType.split(","));
            typeValues.forEach(i -> {
                switch (i) {
                    case "0":
                        this.infoTypeName = StringUtils.hasLength(this.infoTypeName) ? this.infoTypeName.concat(",微信") : "微信";
                        break;
                    case "1":
                        this.infoTypeName = StringUtils.hasLength(this.infoTypeName) ? this.infoTypeName.concat(",邮箱") : "邮箱";
                        break;
                    case "2":
                        this.infoTypeName = StringUtils.hasLength(this.infoTypeName) ? this.infoTypeName.concat(",AI语音") : "AI语音";
                        break;
                }
            });
        }
        this.infoType = infoType;
        return this;
    }


}
